import httpInstance from "@/utils/http.js";
import {useAddressStore} from "@/stores/address.js";

//添加收货地址
export function addAddressAPI(address){
    // 移除 Content-Type 设置，让浏览器自动设置正确的 multipart/form-data 和 boundary
    return httpInstance({
        url:'/user/address/new',
        method:'post',
        data: address
    })
}
//获取所有收货地址
export function getAddressListAPI(uid){
    return httpInstance({
        url:'/user/address/list',
        method:'get',
        params:{
            uid:uid
        },
        headers: {
            'Content-Type': 'application/json',
        }
    })
}

//修改收货地址
export function alterAddressAPI(address){
    // 移除 Content-Type 设置，让浏览器自动设置正确的 multipart/form-data 和 boundary
    return httpInstance({
        url:'/user/address/update',
        method:'put',
        data:address
    })
}

//删除收货地址
export function delAddressAPI(aid){
    return httpInstance({
        url:`/user/address/${aid}`,
        method:'delete',
        headers: {
            'Content-Type': 'application/json',
        }
    })
}